let user = { name: 'Jimmy', xxx: '222' };

function makeProxy(target) {
  return new Proxy(target, {
    get: (target, key) => {
      console.log('这里获取了这个数据，上报!');
      return target[key];
    },
    set: (target, key, value) => {
      if (typeof value !== 'string') {
        console.log('类型错误');
        return;
      }
      target[key] = value;
    },
  });
}

let proxy = makeProxy(user);
console.log(proxy);
console.log(proxy.name);
proxy.name = 111;
